<!-- 商品分类列表 -->
<template>
  <s-layout title="购物车" :bgStyle="{ color: '#fff' }">
    <cart />
  </s-layout>
</template>

<script setup>
  import sheep from '@/sheep';

  import cart from '@/pages/index/components/cartutil.vue';
  import { onMounted, computed } from 'vue';
  import UserApi from '@/sheep/api/member/user';

  onMounted(async () => {
    const isLogin = computed(() => sheep.$store('user').isLogin); //没登录则会被驳回
    // console.log("isLogin", isLogin.value);
    if (!isLogin.value) {
      sheep.$router.go('/pages/index/mainlogin');
    }
    const isName = await UserApi.isNameAuthenication(); //没实名认证则会被驳回
    if (!isName.data) {
      sheep.$router.go('/pages/register/auth-identification');
    }

    const levelId = await UserApi.levelId(); //老用户无需在此页面购买
    if (levelId.data > 0) {
      let intv = setInterval(() => {
        sheep.$helper.toast('欢迎使用本公司净水器');
        sheep.$router.go('/pages/index/index');
        clearInterval(intv);
      }, 1000);
    }
  });

  const onLogout = () => {
    sheep.$store('user').logout();
    sheep.$helper.toast('登出成功，正在返回');
    let value = 0;
    const intv = setInterval(() => {
      sheep.$router.go('/pages/index/mainlogin');
      value++;
      if (value == 1) {
        clearInterval(intv);
      }
    }, 500);
  };
</script>

<style lang="scss" scoped>
  @import '@/sheep/components/s-auth-modal/index.scss';

  .head-box,
  button {
    margin: 30px;
    width: auto;
    height: auto;
  }
</style>
